<%@ page contentType="text/html;charset=UTF-8" trimDirectiveWhitespaces="true"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<c:set var="extLibs" value="validate"/>
<sys:header title="分工会自评 - ${score.isNewRecord ? '新增' : '编辑'}考核打分" extLibs="${extLibs}" htmlClass="scroll"/>
<div class="portlet box ${boxStyleColor} autoHeight">
	<div class="portlet-body form">
		<form:form id="inputForm" modelAttribute="score" action="${ctx}/eva/score/saveScore" method="post" class="form-horizontal">
			<div id="divBillDtl" class="hide">
			</div>
			<div class="table-fdiv">
				<h3>校工会考评</h3>
				<table class="table-form">
					<tr>
						<td class="row-lbl" align="center">一级指标</td>
						<td  class="row-lbl" align="center">二级指标</td>
						<td  class="row-lbl" align="center">考核细则</td>
						<td class="row-lbl" align="center">自评得分</td>
						<td class="row-lbl" align="center">考评得分</td>
					</tr>


					<form:hidden path="currentYear"/>


					<c:forEach items="${targetList}" var="target" varStatus="status">
						<tr>
							<td rowspan="${target.gradeNum}"  class="row-lbl" align="center" width="150px">${target.targetName}（${target.score} 分）</td>
							<td rowspan="${target.targetList[0].gradeNum}" class="row-lbl" align="left" width="250px">${target.targetList[0].targetName}（${target.targetList[0].score} 分）</td>


							<td rowspan="${target.targetList[0].targetList[0].gradeNum}" class="row-lbl" align="left" width="250px">${target.targetList[0].targetList[0].targetName}（${target.targetList[0].targetList[0].score} 分）</td>
							<td align="center">
									<%--评分分值 --%>

								<input id="${target.targetList[0].targetList[0].targetCode}selfScore"  name="${target.targetList[0].targetList[0].targetCode}selfScore"  data-key="${target.targetList[0].targetList[0].targetCode}" data-name="${target.targetList[0].targetList[0].targetName}" data-keyval="${target.targetList[0].targetList[0].targetCode}selfScore" data-score="${target.targetList[0].targetList[0].score}" data-val="selfScore" class="form-control text-center param required" disabled="disabled" />
							</td><td align="center">
									<%--评分分值 --%>

								<input id="${target.targetList[0].targetList[0].targetCode}checkScore"  name="${target.targetList[0].targetList[0].targetCode}checkScore" data-scoreid="" data-key1="${target.targetList[0].targetList[0].targetCode}" data-name="${target.targetList[0].targetList[0].targetName}" data-keyval="${target.targetList[0].targetList[0].targetCode}checkScore" data-score="${target.targetList[0].targetList[0].score}" data-val="selfScore" class="form-control text-center param required"/>
							</td>
						</tr>
						<c:forEach items="${target.targetList}" var="target2" varStatus="status">
							<c:choose>
								<c:when test="${status.count==1}">
									<c:forEach items="${target.targetList[0].targetList}" var="target3" varStatus="status">
										<c:choose>
											<c:when test="${status.count==1}">
											</c:when>
											<c:otherwise>
												<tr>
													<td rowspan="${target3.gradeNum}"  class="row-lbl" align="left">${target3.targetName}（${target3.score} 分）</td>
													<td align="center">
															<%--评分分值 --%>
														<input id="${target3.targetCode}selfScore"  name="${target3.targetCode}selfScore"  data-key="${target3.targetCode}" data-name="${target3.targetName}" data-keyval="${target3.targetCode}selfScore" data-score="${target3.score}" data-val="selfScore" class="form-control text-center param required" disabled="disabled"/>
													</td><td align="center">
															<%--评分分值 --%>
														<input id="${target3.targetCode}checkScore"  name="${target3.targetCode}checkScore"  data-scoreid="" data-key1="${target3.targetCode}" data-name="${target3.targetName}" data-keyval="${target3.targetCode}checkScore" data-score="${target3.score}" data-val="checkScore" class="form-control text-center param required"/>
													</td>
												</tr>
											</c:otherwise>
										</c:choose>
									</c:forEach>
								</c:when>
								<c:otherwise>
									<tr>
										<td rowspan="${target2.gradeNum}"  class="row-lbl" align="left">${target2.targetName}（${target2.score} 分）</td>

										<td rowspan="${target2.targetList[0].gradeNum}"  class="row-lbl" align="left">${target2.targetList[0].targetName}（${target2.targetList[0].score} 分）</td>
										<td align="center">
												<%--评分分值 --%>
											<input id="${target2.targetList[0].targetCode}selfScore"  name="${target2.targetList[0].targetCode}selfScore"  data-key="${target2.targetList[0].targetCode}" data-name="${target2.targetList[0].targetName}" data-keyval="${target2.targetList[0].targetCode}selfScore" data-score="${target2.targetList[0].score}" data-val="selfScore" class="form-control text-center param required" disabled="disabled"/>
										</td><td align="center">
												<%--评分分值 --%>
											<input id="${target2.targetList[0].targetCode}checkScore"  name="${target2.targetList[0].targetCode}checkScore"  data-scoreid="" data-key1="${target2.targetList[0].targetCode}" data-name="${target2.targetList[0].targetName}" data-keyval="${target2.targetList[0].targetCode}checkScore" data-score="${target2.targetList[0].score}" data-val="checkScore" class="form-control text-center param required"/>
										</td>
									</tr>




									<c:forEach items="${target2.targetList}" var="target3" varStatus="status">
										<c:choose>
											<c:when test="${status.count==1}">
											</c:when>
											<c:otherwise>


												<tr>
													<td rowspan="${target3.gradeNum}"  class="row-lbl" align="left">${target3.targetName}（${target3.score} 分）</td>

													<td align="center">
															<%--评分分值 --%>
														<input id="${target3.targetCode}selfScore"  name="${target3.targetCode}selfScore"  data-key="${target3.targetCode}" data-name="${target3.targetName}" data-keyval="${target3.targetCode}selfScore" data-score="${target3.score}" data-val="selfScore" class="form-control text-center param required" disabled="disabled"/>
													</td><td align="center">
															<%--评分分值 --%>
														<input id="${target3.targetCode}checkScore"  name="${target3.targetCode}checkScore" data-scoreid=""  data-key1="${target3.targetCode}" data-name="${target3.targetName}" data-keyval="${target3.targetCode}checkScore" data-score="${target3.score}" data-val="checkScore" class="form-control text-center param required"/>
													</td>
												</tr>
											</c:otherwise>
										</c:choose>
									</c:forEach>





								</c:otherwise>
							</c:choose>
						</c:forEach>




					</c:forEach>


				</table>
				<div class="form-actions">
					<shiro:hasPermission name="eva:score:edit">
						<button id="btnSubmit" type="button" class="btn btn-primary"><i class="fa fa-check"></i> 保 存</button>&nbsp;
					</shiro:hasPermission>
					<button id="btnCancel" type="button" class="btn default" onclick="closeCurrentTabPage('${param.parentTabPageId}')"><i class="fa fa-reply-all"></i> 关 闭</button>
				</div>
			</div>
		</form:form>
	</div>
</div>
<sys:footer extLibs="${extLibs}"/>
<script type="text/javascript">


	$("#inputForm").validate({
		submitHandler: function(form){
			ajaxSubmitForm($(form), function(data){
				showMessage(data.message);
				if(data.result == Global.TRUE){
					closeCurrentTabPage('${param.parentTabPageId}', function(contents, contentWindow){
						contentWindow.page();
					});
				}
			}, "json");
		}
	});

	$('#btnSubmit').click(function(){
		var arrChk=$("input[data-key1]");
		console.log(arrChk);

		$("#divBillDtl").empty();
		var inputArr=[];
		var i=0;



		var flag =false;
		var massage ="";
		$(arrChk).each(function(){

			if(Number($(this).val())>Number($(this).attr("data-score"))){
				flag =true;
				massage=massage+$(this).attr("data-name")+"   ";
			}

			inputArr.push('<input  name="scoreList['+i+'].id" value="'+$(this).attr("data-scoreid")+'"/>');
			inputArr.push('<input  name="scoreList['+i+'].checkScore" value="'+$(this).val()+'"/>');
			i++;

		});

		if (flag){
			showMessage("考核细则："+massage+"不能超过当前最大分数");
			return ;
		}

		$('#divBillDtl').append(inputArr.join(''));

		$("#inputForm").submit();
	});



1
	$(document).ready(function() {


		<c:forEach items="${scoreList}" var="score" varStatus="status">
		console.log("${score.targetCode}");

		var aa ="${score.targetCode}"+"selfScore";

		$("#"+aa).val("${score.selfScore}");

		$("#currentYear").val("${score.currentYear}");


		var bb ="${score.targetCode}"+"checkScore";

		$("#"+bb).attr("data-scoreid","${score.id}");
		$("#"+bb).val("${score.checkScore}");
		</c:forEach>




	});


</script>